package net.colah.k1.core;

import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.MapsId;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.openkoala.koala.commons.domain.KoalaAbstractEntity;

/**
 * Created by sinclair on 4/27/14.
 */
@Entity
@Table(name = "BO_ORDER")
public class Order extends KoalaAbstractEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = -7235708326001574654L;

	public static enum Type {
		INPUT, OUTPUT;
		
		private String name;

		public String getName() {
			return name;
		}

		public void setName(String name) {
			this.name = name;
		}
		
	}

	public static enum State {
		// TODO　订单状态
		WAITING, SHIPPED, ARRIVALS;
		
		private String name;

		public String getName() {
			return name;
		}

		public void setName(String name) {
			this.name = name;
		}
		
		
	}

	/**
	 * 付款账户
	 */
	private Account account;

	/**
	 * 订单编码
	 */
	private String code;
	/**
	 * 订单类型，分为　进货单　或　出货单
	 */
	private Type type;
	/**
	 * 订单状态
	 */
	private State state;

	/**
	 * 订单生成日期
	 */
	private Date createDate;

	/**
	 * 订单完成日期
	 */
	private Date finishDate;

	/**
	 * 订单描述
	 */
	private String desc;

	/**
	 * 订单总金额
	 */
	private BigDecimal sumPrice;

	/**
	 * 运费
	 */
	private BigDecimal freight;

	/**
	 * 备注
	 */
	private String meno;

	@OneToOne
	@MapsId
	public Account getAccount() {
		return account;
	}

	public void setAccount(Account account) {
		this.account = account;
	}

	@Column(name = "CODE")
	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	@Column(name = "TYPE")
	public Type getType() {
		return type;
	}

	public void setType(Type type) {
		this.type = type;
	}

	@Column(name = "STATE")
	public State getState() {
		return state;
	}

	public void setState(State state) {
		this.state = state;
	}

	@Column(name = "DESCRIPTION")
	public String getDesc() {
		return desc;
	}

	public void setDesc(String desc) {
		this.desc = desc;
	}

	@Column(name = "SUM_PRICE")
	public BigDecimal getSumPrice() {
		return sumPrice;
	}

	public void setSumPrice(BigDecimal sumPrice) {
		this.sumPrice = sumPrice;
	}

	@Column(name = "CREATED_DATE")
	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	@Column(name = "FINISHED_DATE")
	public Date getFinishDate() {
		return finishDate;
	}

	public void setFinishDate(Date finishDate) {
		this.finishDate = finishDate;
	}

	@Column(name = "FREIGHT")
	public BigDecimal getFreight() {
		return freight;
	}

	public void setFreight(BigDecimal freight) {
		this.freight = freight;
	}

	@Column(name = "MENO")
	public String getMeno() {
		return meno;
	}

	public void setMeno(String meno) {
		this.meno = meno;
	}

	@Override
	public String[] businessKeys() {
		return new String[0];
	}
}
